package com.sibu.yx.promotion.web.support.model;

import org.apache.shiro.authz.Permission;
import org.apache.shiro.authz.permission.PermissionResolver;
import org.apache.shiro.authz.permission.WildcardPermission;

/**
 * @author     ：yuwenbo
 * @date       ：Created in 2019/4/19 16:23
 * @description：本地解析器
 */
public class CustomPermissionResolver implements PermissionResolver {

    @Override
    public Permission resolvePermission(String permissionString) {
        if(permissionString.startsWith("+")){
            return new BitPermission(Integer.parseInt(permissionString.substring(1)));
        }
        return new WildcardPermission(permissionString);
    }
}
